package edu.bbu.commonproject.desktop.gui.view.swing.base;

import java.awt.CardLayout;
import java.awt.Dimension;

import javax.swing.JFrame;

import edu.bbu.commonproject.desktop.gui.view.BaseFrameInterface;
import edu.bbu.commonproject.desktop.gui.view.swing.file.FileListPanel;
import edu.bbu.commonproject.desktop.gui.view.swing.login.StartViewPanel;
import edu.bbu.commonproject.desktop.gui.view.swing.setup.SetupPanel;
import edu.bbu.commonproject.desktop.gui.view.swing.utils.Design;
import edu.bbu.commonproject.desktop.gui.view.swing.utils.Tray;

/**
 * The base frame.
 */
public class BaseFrame extends JFrame implements BaseFrameInterface
{
	/** The logon view panel. */
	private StartViewPanel logonView;
	
	/** the file list panel. */
	private FileListPanel fileView;
	
	/** The setup panel. */
	private SetupPanel setupView;
	
	/** The tray. */
	private Tray tray;
	
	/** The Card Layout. */
	private CardLayout cardLayout;
	
	/**
	 * The constructor.
	 */
	public BaseFrame()
	{
		Design.setLookAndFeel();
		
		this.setIconImage(Design.BASE_ICON);
		this.setTitle("MongoFS file - share");		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		cardLayout = new CardLayout();
		this.getContentPane().setLayout(cardLayout);
		
		setComponents();
		
		this.pack();
		this.setMinimumSize(new Dimension(930, 710));
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	/**
	 * Sets the components.
	 */
	public void setComponents()
	{
		logonView = new StartViewPanel();
		fileView = new FileListPanel();
		setupView = new SetupPanel();
		tray = new Tray();
		
		this.getContentPane().add(logonView, LOGON_PANEL);
		this.getContentPane().add(fileView, FILES_PANEL);
		this.getContentPane().add(setupView, SETUP_PANEL);
		
		moveToFront(LOGON_PANEL);
	}
	
	/**
	 * It moves the panel to the fron.
	 */
	public void moveToFront(String panelName)
	{
		cardLayout.show(this.getContentPane(), panelName);
	}

	/**
	 * It gets the base frame.
	 */
	public Object getBaseFrame()
	{
		return this;
	}
	
	/**
	 * It gets the logon view.
	 */
	public Object getLogonView()
	{
		return logonView;
	}

	/**
	 * It gets the file view.
	 */
	public Object getFileView()
	{
		return fileView;
	}

	/**
	 * It gets the setup view.
	 */
	public Object getSetupView()
	{
		return setupView;
	}

	/**
	 * It gets the tay icon.
	 */
	public Object getTrayIcon()
	{
		return tray;
	}
}
